<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" language="java" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<header class="main-header">
    <a href="all-admin-index.html" class="logo">
        <span class="logo-mini"><img src="../img/logo.png"></span>
        <span class="logo-lg">
                    <img src="../img/export.png">
                    <i> SaaS外贸进出口平台</i>
                </span>
    </a>

   <%-- <script type="text/javascript">
        //该页面一加载便调用查询邮件个数列表（未读的--is_read=0）函数
        $(document).ready(function () {
            $.ajax({
                type:'post',
                url:'${ctx}/system/feed/totalMessage',
                dataType:'JSON',   //数据格式
                contentType:'application/json',
                success:function (data) {

                    var total = data.sunmer;
                    var html= null;
                    //获取数据
                    html += "<span>"+total+"</span>";
                    $('#num').html(html);  //在html页面id=num的标签里显示html内容
                },
                error:function () {

                     alert("出现异常···")
                }
            });
        })
      }
    </script>
--%>
    <%--<script>
        var time =${sessionScope.loginDate};
        var logintime = new Date(time).getTime();//获取用户登录时的时间毫秒数
        var nowtime = new Date().getTime();//获取当前时间的毫秒数
        var usedTime = nowtime-logintime; //两个时间相差的毫秒数

        //用户登录后，系统消息 距离现在的时间差--最多是分钟
        //计算出分钟
        var min  = usedTime/(1000*60);  //60000 ---70000==1》》10000
        var sec = Math.floor(usedTime%(1000*60));  //计算出秒
        document.getElementById(id).innerHTML = min+"分"+sec+"秒前";
    </script>--%>

    <script>
        var minuteVal = 0;

        function formatSeconds(value) {
            var secondTime = parseInt(value); // 秒
            var minuteTime = 0; // 分
            var hourTime = 0; // 小时
            if (secondTime > 60) { //如果秒数大于60，将秒数转换成整数
                //获取分钟，除以60取整数，得到整数分钟
                minuteTime = parseInt(secondTime / 60);
                //获取秒数，秒数取佘，得到整数秒数
                secondTime = parseInt(secondTime % 60);
                //如果分钟大于60，将分钟转换成小时
                if (minuteTime > 60) {
                    //获取小时，获取分钟除以60，得到整数小时
                    hourTime = parseInt(minuteTime / 60);
                    //获取小时后取佘的分，获取分钟除以60取佘的分
                    minuteTime = parseInt(minuteTime % 60);
                }
            }
            var result = "" + parseInt(secondTime) + "秒";

            if (minuteTime > 0) {
                result = "" + parseInt(minuteTime) + "分" + result;
            }
            if (hourTime > 0) {
                result = "" + parseInt(hourTime) + "小时" + result;
            }
            return result;
        }
        //页面刷新，防止时间从头开始计算--未完成
        function timedCount() {
            minuteVal = parseInt(sessionStorage.getItem("minuteVal")) || 0
            minuteVal++;

            document.getElementById('logintime').innerHTML = "已登陆" + formatSeconds(minuteVal);
            sessionStorage.setItem("minuteVal", minuteVal);
        }
        window.onload = function () {

            setInterval(timedCount, 1000)

        }
    </script>

    <nav class="navbar navbar-static-top">
        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
        </a>
        <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
                <li class="dropdown messages-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-envelope-o"></i>
                        <span class="label label-success" id="num">${fn:length(sessionScope.list)}</span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header">你有${fn:length(sessionScope.list)}个新邮件</li>
                        <li>
                            <ul class="menu">
                                <li>
                                    <a href="#">
                                        <div class="pull-left">
                                            <img src="../img/user2-160x160.jpg" class="img-circle" alt="User Image">
                                        </div>
                                        <h4>
                                            系统消息
                                            <small><i class="fa fa-clock-o" id="logintime"></i></small>
                                        </h4>
                                        <p>欢迎登录系统!</p>
                                    </a>
                                </li>
                                <%--<li>
                                    <a href="#">
                                        <div class="pull-left">
                                            <img src="../img/user3-128x128.jpg" class="img-circle" alt="User Image">
                                        </div>
                                        <h4>
                                            团队消息
                                            <small><i class="fa fa-clock-o"></i> 2 小时前</small>
                                        </h4>
                                        <p>你有新的任务了</p>
                                    </a>
                                </li>
--%>
                            <c:forEach items="${sessionScope.list}" var="feedback" begin="0" end="2" varStatus="status">
                                <li>
                                    <a href="#">
                                        <c:choose>
                                            <c:when test="${status.index==0}">
                                                <div class="pull-left">
                                                    <img src="../img/3.jpg"  class="img-circle" alt="User Image">
                                                </div>
                                            </c:when>
                                            <c:when test="${status.index==1}">
                                                <div class="pull-left">
                                                    <img src="../img/6.jpg" class="img-circle" alt="User Image">
                                                </div>
                                            </c:when>
                                            <c:when test="${status.index==2}">
                                                <div class="pull-left">
                                                    <img src="../img/8.png" class="img-circle" alt="User Image">
                                                </div>
                                            </c:when>
                                        </c:choose>
                                        <h4>
                                            ${feedback.fbpUsername}
                                            <%--<small><i class="fa fa-clock-o"></i><c:if test="<fmt:formatDate value='${feedback.fbDate}' pattern='MM-dd />"  /></small>--%>
                                            <small><i class="fa fa-clock-o"></i><fmt:formatDate value="${feedback.fbDate}" pattern="MM-dd"/></small>
                                        </h4>
                                        <p>${feedback.fbContent}</p>
                                    </a>
                                </li>
                            </c:forEach>
                            </ul>
                        </li>
                        <li class="footer"><a href="/system/feed/findMessage.do?">查看所有留言</a></li>
                    </ul>
                </li>
                <!-- Notifications: style can be found in dropdown.less -->
                <li class="dropdown notifications-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-bell-o"></i>
                        <span class="label label-warning">10</span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header">你有10个新消息</li>
                        <li>
                            <!-- inner menu: contains the actual data -->
                            <ul class="menu">
                                <li>
                                    <a href="#">
                                        <i class="fa fa-users text-aqua"></i> 5 new members joined today
                                    </a>
                                </li>
                                <li>
                                    <a href="#">
                                        <i class="fa fa-warning text-yellow"></i> Very long description here that may not
                                        fit into the page and may cause design problems
                                    </a>
                                </li>
                                <li>
                                    <a href="#">
                                        <i class="fa fa-users text-red"></i> 5 new members joined
                                    </a>
                                </li>
                                <li>
                                    <a href="#">
                                        <i class="fa fa-shopping-cart text-green"></i> 25 sales made
                                    </a>
                                </li>
                                <li>
                                    <a href="#">
                                        <i class="fa fa-user text-red"></i> You changed your username
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li class="footer"><a href="#">View all</a></li>
                    </ul>
                </li>
                <!-- Tasks: style can be found in dropdown.less -->
                <li class="dropdown tasks-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-flag-o"></i>
                        <span class="label label-danger">9</span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header">你有9个新任务</li>
                        <li>
                            <!-- inner menu: contains the actual data -->
                            <ul class="menu">
                                <li>
                                    <!-- Task item -->
                                    <a href="#">
                                        <h3>
                                            Design some buttons
                                            <small class="pull-right">20%</small>
                                        </h3>
                                        <div class="progress xs">
                                            <div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
                                                <span class="sr-only">20% Complete</span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <!-- end task item -->
                                <li>
                                    <!-- Task item -->
                                    <a href="#">
                                        <h3>
                                            Create a nice theme
                                            <small class="pull-right">40%</small>
                                        </h3>
                                        <div class="progress xs">
                                            <div class="progress-bar progress-bar-green" style="width: 40%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
                                                <span class="sr-only">40% Complete</span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <!-- end task item -->
                                <li>
                                    <!-- Task item -->
                                    <a href="#">
                                        <h3>
                                            Some task I need to do
                                            <small class="pull-right">60%</small>
                                        </h3>
                                        <div class="progress xs">
                                            <div class="progress-bar progress-bar-red" style="width: 60%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
                                                <span class="sr-only">60% Complete</span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <!-- end task item -->
                                <li>
                                    <!-- Task item -->
                                    <a href="#">
                                        <h3>
                                            Make beautiful transitions
                                            <small class="pull-right">80%</small>
                                        </h3>
                                        <div class="progress xs">
                                            <div class="progress-bar progress-bar-yellow" style="width: 80%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
                                                <span class="sr-only">80% Complete</span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                                <!-- end task item -->
                            </ul>
                        </li>
                        <li class="footer">
                            <a href="#">View all tasks</a>
                        </li>
                    </ul>
                </li>
                <!-- User Account: style can be found in dropdown.less -->
                <li class="dropdown user user-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <img src="../img/user2-160x160.jpg" class="user-image" alt="User Image">
                        <span class="hidden-xs"> ${sessionScope.loginUser.userName}</span>
                    </a>
                    <ul class="dropdown-menu">
                        <!-- User image -->
                        <li class="user-header">
                            <img src="../img/user2-160x160.jpg" class="img-circle" alt="User Image">

                            <p>
                                ${sessionScope.loginUser.userName}
                            </p>
                        </li>
                        <!-- Menu Body
                <li class="user-body">
                    <div class="row">
                        <div class="col-xs-4 text-center">
                            <a href="#">Followers</a>
                        </div>
                        <div class="col-xs-4 text-center">
                            <a href="#">Sales</a>
                        </div>
                        <div class="col-xs-4 text-center">
                            <a href="#">Friends</a>
                        </div>
                    </div>
                </li>-->
                        <!-- Menu Footer-->
                        <li class="user-footer">
                            <c:if test="${sessionScope.loginUser.wxunionid != null}">
                                <div class="pull-left">
                                    <a href="/wxdl.do" class="btn btn-default btn-flat">微信解绑</a>
                                </div>
                            </c:if>
                            <div class="pull-left">
                                <a href="#" class="btn btn-default btn-flat">修改密码</a>
                            </div>
                            <div class="pull-right">
                                <a href="/logout.do" class="btn btn-default btn-flat">注销</a>
                            </div>
                        </li>
                    </ul>
                </li>

            </ul>
        </div>
    </nav>
</header>
<!-- 页面头部 /-->

